//
//  MAUIDelegate.h
//  Pods
//
//  Created by elvisgao on 2019/11/27.
//

#import <Foundation/Foundation.h>
#import "AlertActionInfo.h"
#import "QMAModelUtils.h"
#import "MABaseApplication.h"

@class WKWebView;
@class WKWebViewConfiguration;

NS_ASSUME_NONNULL_BEGIN

@protocol QMAUIDelegate <NSObject>

@optional
/// 调节value适配屏幕宽
/// @param value 待适配宽度
- (CGFloat)fitScreenW:(CGFloat)value;

/// 调节value适配屏幕高
/// @param value 待适配高度
- (CGFloat)fitScreenH:(CGFloat)value;


/// 展示loading
/// @param infos loading信息
- (void)showLoading:(QMALoadingInfo * _Nullable)infos;


/// 隐藏loading
- (void)hideLoading;


/// 展示toast
/// @param infos toast信息
/// @param application 小程序/小游戏实例
- (void)showToast:(QMAToastInfo *)infos application:(MABaseApplication *)application;


/// 隐藏toast
- (void)hideToast;

/// 隐藏loading
/// @param webviewID 针对特定的webview
- (void)hideToastWithWebviewID:(NSInteger)webviewID;

/// 展示actionSheet
/// @param title 标题
/// @param cancelButtonTitle 取消按钮标题
/// @param cancelAction 点击取消按钮触发的动作
/// @param otherButtonTitleAndActions 其他按钮及响应操作
/// @param dismissBlock actionSheet收起后需要执行的操作（一定要调用以保证功能正确！！！）
/// @param presentingViewController 展示actionSheet的vc
- (void)showActionSheetWithTitle:(nullable NSString *)title
               cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                    cancelAction:(nullable dispatch_block_t)cancelAction
      otherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActions
                    dismissBlock:(nullable dispatch_block_t)dismissBlock
        presentingViewController:(UIViewController *)presentingViewController;


/// 分享面板
/// 如果此方法不实现，则会调用showActionSheetWithTitle:cancelButtonTitle:cancelAction:otherButtonTitleAndActions:dismissBlock:presentingViewController:
/// @param title 标题
/// @param cancelAction 取消操作
/// @param otherButtonTitleAndActions 其他按钮及响应操作
/// @param dismissBlock 面板收起后需要执行的操作（一定要调用以保证功能正确！！！）
/// @param parentVC 呼起面板的vc
- (void)showShareViewWithTitle:(nullable NSString *)title
                  cancelAction:(nullable dispatch_block_t)cancelAction
    otherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActions
                  dismissBlock:(nullable dispatch_block_t)dismissBlock
                      parentVC:(UIViewController *)parentVC;

/// 点击胶囊按钮呼起的面板
/// 如果此方法不实现，则会调用showActionSheetWithTitle:cancelButtonTitle:cancelAction:otherButtonTitleAndActions:dismissBlock:presentingViewController:
/// @param app 小程序/小游戏实例
/// @param cancelButtonTitle 取消标题
/// @param cancelAction 取消操作
/// @param otherButtonTitleAndActions 其他按钮及响应操作
/// @param dismissBlock 面板收起后需要执行的操作（一定要调用以保证功能正确！！！）
- (UIView *)showMoreButtonActionSheetWithApp:(MABaseApplication *)app
                           cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                                cancelAction:(nullable dispatch_block_t)cancelAction
                  otherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActions
                                dismissBlock:(nullable dispatch_block_t)dismissBlock;

/// 收起所有小程序/小游戏呼起的actionSheet
- (void)clearAllActionSheet;

/**
 * @brief 展示alert弹窗
 *
 * @param title 标题
 * @param message 信息
 * @param actionTitleAndblocks 按钮标题及响应操作
 * @param dismissOnClickBlank 当点击空白背景区域时是否消失
 * @param presentingViewController 呼起alert弹框的vc
 */
- (void)showAlertWithTitle:(nullable NSString *)title
               withMessage:(nullable NSString *)message
              actionBlocks:(nullable NSArray<AlertActionInfo *> *)actionTitleAndblocks
       dismissOnClickBlank:(BOOL)dismissOnClickBlank
  presentingViewController:(UIViewController *)presentingViewController;

/// 呼起alert弹框
/// @param title 标题
/// @param message 信息
/// @param actionTitleAndblocks 按钮标题及响应操作
/// @param presentingViewController 呼起alert弹框的vc
- (void)showAlertWithTitle:(nullable NSString *)title
               withMessage:(nullable NSString *)message
              actionBlocks:(nullable NSArray<AlertActionInfo *> *)actionTitleAndblocks
  presentingViewController:(UIViewController *)presentingViewController;

/**
 * @brief 展示弹窗
 *
 * @param title 标题
 * @param message 信息
 * @param actionTitleAndblocks 按钮标题及响应操作
 * @param isDismissWhenBackground 当小程序退到后台时，弹窗是否消失
 * @param dismissOnClickBlank 当点击空白背景区域时是否消失
 * @param presentingViewController 呼起alert弹框的vc
 */
- (void)showPopupWithTitle:(NSString *)title
                   message:(NSString *)message
              actionBlocks:(NSArray<AlertActionInfo *> *)actionTitleAndblocks
   isDismissWhenBackground:(BOOL)isDismissWhenBackground
       dismissOnClickBlank:(BOOL)dismissOnClickBlank
  presentingViewController:(UIViewController *)presentingViewController;

/**
 * @brief 展示弹窗
 *
 * @param title 标题
 * @param message 信息
 * @param actionTitleAndblocks 按钮标题及响应操作
 * @param isDismissWhenBackground 当小程序退到后台时，弹窗是否消失
 * @param dismissOnClickBlank 当点击空白背景区域时是否消失
 * @param checkBoxTitle 复选框内容
 * @param checkBoxSelected 复选框默认状态
 * @param presentingViewController 呼起alert弹框的vc
 */
- (void)showPopupWithTitle:(NSString *)title
                   message:(NSString *)message
              actionBlocks:(NSArray<AlertActionInfo *> *)actionTitleAndblocks
   isDismissWhenBackground:(BOOL)isDismissWhenBackground
       dismissOnClickBlank:(BOOL)dismissOnClickBlank
             checkBoxTitle:(NSString *)checkBoxTitle
          checkBoxSelected:(BOOL)checkBoxSelected
  presentingViewController:(UIViewController *)presentingViewController;

/**
 * @brief 展示弹窗
 *
 * @param title 标题
 * @param message 信息
 * @param actionTitleAndblocks 按钮标题及响应操作
 * @param isDismissWhenBackground 当小程序退到后台时，弹窗是否消失
 * @param presentingViewController 呼起alert弹框的vc
 */
- (void)showPopupWithTitle:(NSString *)title
                   message:(NSString *)message
              actionBlocks:(NSArray<AlertActionInfo *> *)actionTitleAndblocks
   isDismissWhenBackground:(BOOL)isDismissWhenBackground
  presentingViewController:(UIViewController *)presentingViewController;

/// 宿主App可以自定义分享途径、决定展示顺序，目前使用在点击更多按钮、button组件(open-type="share")呼起的ActionSheet中
/// 1、默认渠道：QQ好友、QQ空间、微信、朋友圈（具体type参见MAUIDelegateShareViewType），由开发商决定，宿主App只能更改展示顺序
/// 2、自定义渠道：宿主App自定义（type填MAUIDelegateShareViewTypeCustomizedShare）
/// 以上两种渠道展示顺序支持混排
- (NSArray<QMASheetItemInfo *> *)customizedConfigForShare;

/// 宿主App可以返回一个自定义的WKWebView，目前用于
/// 1. web-view组件：需要解决web-view组件中用xhr发送post请求body丢失问题
- (WKWebView *)webViewWithConfiguration:(WKWebViewConfiguration *)configuration;

/// 宿主App是否处于DarkMode模式
- (BOOL)isDarkMode;

/// 当前最上层的VC
- (nullable UIViewController *)topViewController;

/// 跳转到界面
- (void)navigateToViewController:(UIViewController *)viewController animated:(BOOL)animated;

/// 回退界面
- (void)navigateBackWithAnimated:(BOOL)animated;

@end

NS_ASSUME_NONNULL_END
